package com.xc.controller.backend;

import com.xc.common.ServerResponse;
import com.xc.service.ISiteLoginLogService;
import com.xc.service.ISiteSmsLogService;
import com.xc.service.ISiteTaskLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author mipha
 * @version 1.0
 * @date 2019/3/14 10:36 PM
 */
@Controller
@RequestMapping("/admin/log/")
@Slf4j
public class AdminLogsController {

    @Autowired
    ISiteLoginLogService iSiteLoginLogService;
    @Autowired
    ISiteTaskLogService iSiteTaskLogService;
    @Autowired
    ISiteSmsLogService iSiteSmsLogService;


    /**
     *  定时任务执行日志
     * @param taskType
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("taskList.do")
    @ResponseBody
    public ServerResponse taskList(
            @RequestParam(value = "taskType", required = false) String taskType
            ,@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            ,@RequestParam(value = "pageSize", defaultValue = "10") int pageSize
            ){
        return iSiteTaskLogService.taskList(taskType,pageNum,pageSize);
    }


    /**
     *  登陆日志列表
     * @param userId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("loginList.do")
    @ResponseBody
    public ServerResponse loginList(
            @RequestParam(value = "userId", required = false) Integer userId
            ,@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            ,@RequestParam(value = "pageSize", defaultValue = "10") int pageSize
    ){
        return iSiteLoginLogService.loginList(userId,pageNum,pageSize);
    }


    /**
     *  短信发送日志
     * @param phoneNum
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("smsList.do")
    @ResponseBody
    public ServerResponse smsList(
            @RequestParam(value = "phoneNum", required = false) String phoneNum
            ,@RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            ,@RequestParam(value = "pageSize", defaultValue = "10") int pageSize
    ){
        return iSiteSmsLogService.smsList(phoneNum,pageNum,pageSize);
    }



}
